//线段树-分治
//单点修改 + 区间查询

#include <iostream>
using namespace std;
const int N = 5e5 + 10;
#define lc p << 1
#define rc p << 1 | 1
typedef long long ll;
ll a[N];

struct node
{
    int l, r;
    ll sum;
    ll max, lmax, rmax; //最大字段和, 从左端点开始的最大和, 从右端点开始的最大和
}tr[N << 2];

void pushup(node& p, node l, node r)
{
    p.sum = l.sum + r.sum;
    p.max = max(l.max, max(r.max, l.rmax + r.lmax));
    p.lmax = max(l.lmax, l.sum + r.lmax); 
    p.rmax = max(r.rmax, r.sum + l.rmax);
}

void build(int p, int l, int r)
{
    tr[p] = {l, r, a[l], a[l], a[l], a[l]};
    if(l == r) return;
    int mid = (l + r) >> 1;
    build(lc, l, mid); build(rc, mid + 1, r);
    pushup(tr[p], tr[lc], tr[rc]);
}

//单点修改
void modify(int p, int x, int k)
{
    int l = tr[p].l, r = tr[p].r;
    if(x == l && r == x)
    {
        tr[p].sum = tr[p].lmax = tr[p].rmax = tr[p].max = k;
        return;
    }
    int mid = (l + r) >> 1;
    if(x <= mid) modify(lc, x, k);
    else modify(rc, x, k);
    pushup(tr[p], tr[lc], tr[rc]);
}

//区间查询
//1.不能只返回一个max, 因为求最大子段和要对左右孩子信息进行整合, 因此需要返回结构体(max, lmax, rmax, sum)
//2.分类讨论更加细致, y <= mid 或 x > mid 不需要整合, 否则需要整合
node query(int p, int x, int y)
{
    int l = tr[p].l, r = tr[p].r;
    if(x <= l && r <= y) return tr[p];
    int mid = (l + r) >> 1;
    if(y <= mid) return query(lc, x, y);
    if(x > mid) return query(rc, x, y);
    node ret, L = query(lc, x, y), R = query(rc, x, y);
    pushup(ret, L, R);
    return ret;
}

int main()
{
    int n, m; cin >> n >> m;
    for(int i = 1; i <= n; i++) cin >> a[i];
    build(1, 1, n);
    while(m--)
    {
        int op, x, y; cin >> op >> x >> y;
        if(op == 1)
        {
            if(x > y) swap(x, y);
            cout << query(1, x, y).max << endl;
        }
        else
        {
            modify(1, x, y);
        }
    }
    return 0;
}